package com.seecen.HJM.controller;

import com.seecen.HJM.model.dto.SongDto;
import com.seecen.HJM.model.vo.SongDetailVo;
import com.seecen.HJM.model.vo.SongVo;
import com.seecen.HJM.result.DataVo;
import com.seecen.HJM.result.PageResult;
import com.seecen.HJM.service.SongService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author TOYA
 * @date 2025/9/26 14:45
 * @description: 歌曲管理控制层
 */


@RestController
@RequestMapping("/song")
public class SongController {

    @Autowired
    private SongService songService;


    //获取所有歌曲 前台歌曲管理直接显示  分页
    @PostMapping("/getAllSongs")
    public DataVo<PageResult<SongVo>> getAllSongs(
            @RequestBody
            @Valid SongDto songDto, HttpServletRequest request
    ) {
        return songService.getAllSongs(songDto, request);
    }

    //获取推荐歌曲 前台显示
    @GetMapping("/getRecommendedSongs")
    public DataVo<List<SongVo>> getRecommendedSongs(
            HttpServletRequest request
    ) {
        return songService.getRecommendedSongs(request);
    }

    //获取歌曲详情  前台显示
    @GetMapping("/getSongDetail/{id}")
    public DataVo<SongDetailVo> getSongDetail(
            @PathVariable("id") Long id,
            HttpServletRequest request
    ) {
        return songService.getSongDetail(id, request);
    }


}
